package cn.tedu._04mybatis;

import cn.tedu._04mybatis.mapper.CommentMapper;
import cn.tedu._04mybatis.pojo.entity.Comment;
import cn.tedu._04mybatis.vo.CommentVo1;
import cn.tedu._04mybatis.vo.CommentVo2;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.Date;
import java.util.List;

/**
 * @Author Justin Parker
 * @Date 2024/8/5 0005 11:56
 * @Version 1.0
 */
@SpringBootTest
public class CommentTexts {

    @Autowired
    private CommentMapper commentMapper;

    @Test
    void InsertComment() {
        Comment comment = new Comment();
        comment.setContent("无极之道在我内心延续！");
        comment.setCreated(new Date());
        comment.setUserId(103L);
        comment.setWeiboId(209L);
        int i =commentMapper.insertComment(comment);
        System.out.println("插入"+ i +"条数据成功！");
    }

    @Test
    void DeleteComment() {
        Comment comment = new Comment();
        comment.setId(306L);
        int i = commentMapper.deleteComment(comment);
        System.out.println("删除"+ i +"条数据成功！");
    }

    @Test
    void UpdateComment() {
        Comment comment = new Comment();
        comment.setId(306L);
        comment.setContent("无极之道在我内心延续！");
        comment.setCreated(new Date());
        int i = commentMapper.updateComment(comment);
        System.out.println("更新"+ i +"条数据成功！");
    }

    @Test
    void SelectComment() {
        CommentVo1 comment = commentMapper.selectCommentVo1(305L);
        System.out.println(comment);
    }

    @Test
    void SelectComment2() {
        List<CommentVo2> comment = commentMapper.selectCommentVo2(201L);
        System.out.println(comment);
    }


}
